package com.yfree.utils;

public class YCharUtils {
    public static boolean isChineseByString(String str) {
        char[] nickchar = str.toCharArray();
        for (char aNickchar : nickchar) {
            if (!isChinesebyChar(aNickchar)) {
                return false;
            }
        }
        return true;
    }

    private static boolean isChinesebyChar(char c) {
        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
        return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS;
    }
}
